<style>
    .tools{margin: -20px -5px;}
    .tools a{background: white;border-radius: 3px;-webkit-border-radius: 3px;color: #858582;float: left;
        margin-left: 10px;padding: 10px;text-decoration: none;}
    .tools a:first-child{background-image: url('/Public/images/minus.png');background-repeat:no-repeat;background-position: 50% center;}
    .tools a:nth-child(2){margin-right: 20px;background-image: url('/Public/images/plus-small.png');background-repeat:no-repeat;background-position: 50% center;}
</style>
<div id="page-wrapper">
    <div class="row">
		<div class="col-lg-12">
			<h3 class="page-header">
                <present name="red_packet">编辑<else/>添加</present>红包雨
			</h3>
		</div>
	</div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <ul class="nav nav-tabs" id="myTab">
                        <li class="active"><a href="#basic">基础设置</a></li>
                        <li><a href="#award">奖项设置</a></li>
                        <li><a href="#more">推送设置</a></li>
                        <li><a href="#share">分享设置</a></li>
                        <li><a href="#audio">音效设置</a></li>
                    </ul>
                </div>
                <div class="panel-body">
                    <form role="form" class="form-horizontal" action="{:U('User/RedPacket/update')}" method="post" enctype="multipart/form-data" onsubmit="return formcheck();">
                        <present name="red_packet.id">
                            <input type="hidden" name="id" value="{$red_packet['id']}">
                        <else />
                            <input type="hidden" name="id" value="-1">
                        </present>
                        <div class="tab-content">
                            <div class="tab-pane active" id="basic">
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 活动标题</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.title">
                                            <input class="form-control valid" name="title" title="请输入活动标题" value="{$red_packet['title']}" placeholder="请输入活动标题">
                                        <else />
                                            <input class="form-control valid" name="title" title="请输入活动标题" placeholder="请输入活动标题">
                                        </present>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 开始时间</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.startdate">
                                            <input class="form-control date-picker valid" title="请输入活动开始时间" id="start" name="startdate" value="{$red_packet['startdate']}" placeholder="请输入活动开始时间" readonly>
                                        <else />
                                            <input class="form-control date-picker valid" title="请输入活动开始时间" id="start" name="startdate" value="" placeholder="请输入活动开始时间" readonly>
                                        </present>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 结束时间</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.enddate">
                                            <input class="form-control date-picker valid" title="请输入活动结束时间" id="end" name="enddate" value="{$red_packet['enddate']}" placeholder="请输入活动结束时间" readonly>
                                        <else />
                                            <input class="form-control date-picker valid" title="请输入活动结束时间" id="end" name="enddate" value="" placeholder="请输入活动结束时间" readonly>
                                        </present>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 活动规则</label>
                                    <div class="col-lg-6">
                                        <textarea id="editor-container" style="width:550px;height:300px;" name="info" title="请输入活动规则"></textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 每日中奖次数上限</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.number_limits">
                                            <input class="form-control valid" title="请输入每日中奖次数上限" name="number_limits" value="{$red_packet['number_limits']}">
                                            <else />
                                            <input class="form-control valid" title="请输入每日中奖次数上限" name="number_limits" value="">
                                        </present>
                                        <p class="help-block">如若忽略，请填-1</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 每人中奖次数</label>
                                    <div class="col-lg-6 input-group" style="padding-left:15px">
                                        <span class="input-group-addon">每人最多可中奖</span>
                                        <present name="red_packet.per_num_sum">
                                            <input class="form-control valid" title="请输入中奖次数" name="per_num_sum" value="{$red_packet['per_num_sum']}">
                                        <else />
                                            <input class="form-control valid" title="请输入中奖次数" name="per_num_sum" value="">
                                        </present>
                                        <span class="input-group-addon">次</span>
                                    </div>
                                </div>
                                <!--<div class="form-group">-->
                                    <!--<label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 总中奖率</label>-->
                                    <!--<div class="col-lg-6 input-group" style="padding-left:15px">-->
                                        <!--<present name="red_packet.total_rate">-->
                                            <!--<input class="form-control valid" title="请填写大于或等于0中奖概率" name="total_rate" value="{$red_packet['total_rate']}">-->
                                        <!--<else />-->
                                            <!--<input class="form-control valid" title="请填写大于或等于0中奖概率" name="total_rate" value="">-->
                                        <!--</present>-->
                                        <!--<span class="input-group-addon">%</span>-->
                                    <!--</div>-->
                                    <!--<p class="help-block" style="padding-left:190px">请填写大于或等于0的数字</p>-->
                                <!--</div>-->
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 每人每日游戏次数上限</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.per_num">
                                            <input class="form-control valid" title="请输入次数上限" name="per_num" value="{$red_packet['per_num']}">
                                        <else />
                                            <input class="form-control valid" title="请输入次数上限" name="per_num" value="">
                                        </present>
                                        <p class="help-block">如若忽略，请填-1</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 游戏时间</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.game_time">
                                            <input class="form-control valid" title="请输入游戏时间" name="game_time" value="{$red_packet['game_time']}">
                                        <else />
                                            <input class="form-control valid" title="请输入游戏时间" name="game_time" value="">
                                        </present>
                                        <p class="help-block">建议设置成30秒</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">额外游戏次数</label>
                                    <div class="col-lg-6">
                                        <input class="form-control" name="share_play" value="{$red_packet['share_play']}">
                                        <p class="help-block">（其它活动）通过微信分享到朋友圈或好友成功时，可获得额外游戏次数</p>
                                    </div>
                                </div>

                                <!--使用临时字段-->

                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">起始速度</label>
                                    <div class="col-lg-6">
                                        <input class="form-control" name="start_speed" value="<?php
                                            if(empty($red_packet) || empty($red_packet['reserve'])){
                                                echo 0.2;
                                            }else{
                                                $reserve = json_decode($red_packet['reserve'],true);
                                                if(!empty($reserve['start_speed'])){
                                                    echo $reserve['start_speed'];
                                                }else{
                                                    echo 0.2;
                                                }
                                            }
                                        ?>">
                                        <p class="help-block">第一个红包下落的速度（数值越大速度越快，建议设置为0.2）</p>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">最终速度</label>
                                    <div class="col-lg-6">
                                        <input class="form-control" name="end_speed" value="<?php
                                            if(empty($red_packet) || empty($red_packet['reserve'])){
                                                echo 3;
                                            }else{
                                                $reserve = json_decode($red_packet['reserve'],true);
                                                if(!empty($reserve['end_speed'])){
                                                    echo $reserve['end_speed'];
                                                }else{
                                                    echo 3;
                                                }
                                            }
                                        ?>">
                                        <p class="help-block">最后一个红包下落的速度（数值越大速度越快，建议最大为3）</p>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">红包比例</label>
                                    <div class="col-lg-6">
                                        <input class="form-control" name="redpacket_rate" value="<?php
                                            if(empty($red_packet) || empty($red_packet['reserve'])){
                                                echo 0.65;
                                            }else{
                                                $reserve = json_decode($red_packet['reserve'],true);
                                                if(!empty($reserve['redpacket_rate'])){
                                                    echo $reserve['redpacket_rate'];
                                                }else{
                                                    echo 0.65;
                                                }
                                            }
                                        ?>">
                                        <p class="help-block">红包与炸弹的比例（0-1，1为都是红包）</p>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">再玩一次链接</label>
                                    <div class="col-lg-6">
                                        <input class="form-control" name="again_url" value="<?php
                                            if(empty($red_packet) || empty($red_packet['reserve'])){
                                                echo '';
                                            }else{
                                                $reserve = json_decode($red_packet['reserve'],true);
                                                if(!empty($reserve['again_url'])){
                                                    echo $reserve['again_url'];
                                                }else{
                                                    echo '';
                                                }
                                            }
                                        ?>">
                                        <p class="help-block">再玩一次链接（不填为本红包雨活动）</p>
                                    </div>
                                </div>
                                <!--使用临时字段结束-->

                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label">是否可分享</label>
                                    <div class="col-lg-6">
                                        <input type="radio" name="share_able" value="0" <?php
                                    if(empty($red_packet) || empty($red_packet['share_able'])){
                                        echo " checked ";
                                    }
                                    ?>>是
                                                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                                                    <input type="radio" name="share_able" value="1" <?php
                                    if(!empty($red_packet) && !empty($red_packet['share_able'])){
                                        echo " checked ";
                                    }
                                    ?>>否
                                        <p class="help-block">红包雨活动是否可以分享</p>
                                    </div>
                                </div>

                            </div>

                            <div class="tab-pane" id="award">
                                <section class="panel">
                                    <header class="panel-heading custom-tab">
                                        <ul class="nav nav-tabs" id="award_tab">
                                            <li class="active">
                                                <a href="#award1" data-item="{$f}" data-toggle="tab">奖项1</a>
                                            </li>
                                            <volist name="red_packet_items" id="item" offset="1">
                                                <li>
                                                    <a href="#award{$i+1}" data-item="{$item['id']}" data-toggle="tab">奖项{$i+1}</a>
                                                </li>
                                            </volist>
                                        </ul>
                                        <empty name="red_packet_items">
                                            <input type="hidden" name="award_num" value="1">
                                            <else/>
                                            <input type="hidden" name="award_num" value="{$red_packet_items|count}">
                                        </empty>
                                        <span class="tools pull-right">
                                            <a class="" href="javascript:;" onclick="deleteaward();"></a>
                                            <a class="" href="javascript:;" onclick="addaward();"></a>
                                        </span>
                                    </header>
                                    <div class="panel-body">
                                        <div class="tab-content" id="award_content">
                                            <div class="tab-pane active" id="award1">
                                                <input type="hidden" name="item_id1" value="{$f}">
                                                <div class="form-group">
                                                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span> 奖项等级</label>
                                                    <div class="col-sm-6 col-xs-12">
                                                        <div class="form-control-static">
                                                            <select name="level1" class="form-control">
                                                                <volist name="levels" id="level">
                                                                    <option value="{$i}" <if condition="$i eq $red_packet_items[0]['level']">selected</if>>{$level}</option>
                                                                </volist>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项名称</label>
                                                    <div class="col-lg-6">
                                                        <empty name="red_packet_items">
                                                            <input class="form-control valid" title="请输入奖项名称" name="name1">
                                                        <else />
                                                            <volist name="red_packet_items" id="item" offset="0" length="1">
                                                                <input class="form-control valid" title="请输入奖项名称" name="name1" value="{$item['name']}">
                                                            </volist>
                                                        </empty>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项数量</label>
                                                    <div class="col-lg-6">
                                                        <empty name="red_packet_items">
                                                            <input class="form-control valid" title="请输入奖项数量" name="number1">
                                                        <else />
                                                            <volist name="red_packet_items" id="item" offset="0" length="1">
                                                                <input class="form-control valid" title="请输入奖项数量" name="number1" value="{$item['number']}">
                                                            </volist>
                                                        </empty>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 中奖概率(0.00001-100.00000)</label>
                                                    <div class="col-lg-6">
                                                        <empty name="red_packet_items">
                                                            <input class="form-control valid" title="请输入中奖概率" name="reserve1">
                                                        <else />
                                                            <volist name="red_packet_items" id="item" offset="0" length="1">
                                                                <input class="form-control valid" title="请输入中奖概率" name="reserve1" value="{$item['reserve']}">
                                                            </volist>
                                                        </empty>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 col-sm-2 control-label"> 奖项图片</label>
                                                    <div class="col-lg-6">
                                                        <empty name="red_packet_items">
                                                            <img src="" class="thumbnail preview" width="100px" height="100px" data-preview="uploadFile1">
                                                            <input name="pic1" type="file" data-action="uploadFile1">
                                                        <else />
                                                            <volist name="red_packet_items" id="item" offset="0" length="1">
                                                                <if condition="$item['pic'] eq null">
                                                                    <img src="" class="thumbnail" width="100px" height="100px" data-preview="uploadFile1">
                                                                <else/>
                                                                    <img src="/{$item['pic']}" class="thumbnail" width="100px" height="100px" data-preview="uploadFile1">
                                                                </if>
                                                                <input type="hidden" name="pic1" value="{$item['pic']}" data-set="uploadFile1">
                                                                <input type="file" class="changePic" data-action="uploadFile1">
                                                            </volist>
                                                        </empty>
                                                        <p class="help-block">建议上传图片尺寸：80*60</p>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 col-sm-2 control-label">自定义属性</label>
                                                    <div class="col-lg-6">
                                                        <table class="table" id="attr-table1" <if condition="($id eq -1) OR ($red_packet_items[0]['attribute'] eq null)">style="display:none"</if>>
                                                            <thead>
                                                                <tr>
                                                                    <th style='width:50px;'></th>
                                                                    <th style="text-align: center">属性名称</th>
                                                                    <th style="text-align: center">属性值</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody id="attr-items1">
                                                                <volist name="red_packet_items[0]['attribute']" id="attribute">
                                                                    <tr>
                                                                        <td>
                                                                            <a href="javascript:;" onclick="deleteAttr(this)" title="删除"><i class='fa fa-remove'></i></a>
                                                                        </td>
                                                                        <td>
                                                                            <input class="form-control" name="attribute_title1[]" value="{$key}">
                                                                        </td>
                                                                        <td>
                                                                            <input class="form-control" name="attribute_value1[]" value="{$attribute}">
                                                                        </td>
                                                                    </tr>
                                                                </volist>
                                                            </tbody>
                                                        </table>

                                                        <a href="javascript:;" onclick="addAttr1()" class="btn btn-default"  title="添加属性"><i class='fa fa-plus'></i> 添加属性</a>
                                                    </div>
                                                </div>
                                            </div>
                                            <volist name="red_packet_items" id="item" offset="1" key="k">
                                                <div class="tab-pane" id="award{$k+1}">
                                                    <input type="hidden" name="item_id{$k+1}" value="{$item['id']}">
                                                    <div class="form-group">
                                                        <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span> 奖项等级</label>
                                                        <div class="col-sm-6 col-xs-12">
                                                            <div class="form-control-static">
                                                                <select name="level{$k+1}" class="form-control">
                                                                    <volist name="levels" key="key_level" id="level">
                                                                        <option value="{$key_level}" <if condition="$key_level eq $item['level']">selected</if>>{$level}</option>
                                                                    </volist>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项名称</label>
                                                        <div class="col-lg-6">
                                                            <input class="form-control valid" title="请输入奖项名称" name="name{$k+1}" value="{$item['name']}">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项数量</label>
                                                        <div class="col-lg-6">
                                                            <input class="form-control valid" title="请输入奖项数量" name="number{$k+1}" value="{$item['number']}">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 中奖概率</label>
                                                        <div class="col-lg-6">
                                                            <input class="form-control valid" title="请输入中奖概率" name="reserve{$k+1}" value="{$item['reserve']}">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg-2 col-sm-2 control-label"> 奖项图片</label>
                                                        <div class="col-lg-6">
                                                            <if condition="$item['pic'] eq null">
                                                                <img src="" class="thumbnail" width="100px" height="100px" data-preview="uploadFile{$k+1}">
                                                            <else/>
                                                                <img src="/{$item['pic']}" class="thumbnail" width="100px" height="100px" data-preview="uploadFile{$k+1}">
                                                            </if>
                                                            <input type="hidden" name="pic{$k+1}" value="{$item['pic']}" data-set="uploadFile{$k+1}">
                                                            <input type="file" class="changePic" data-action="uploadFile{$k+1}">
                                                            <p class="help-block">建议上传图片尺寸：80*60</p>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg-2 col-sm-2 control-label">自定义属性</label>
                                                        <div class="col-lg-6">
                                                            <table class="table" id="attr-table{$k+1}" <if condition="$item['attribute'] eq null">style="display:none"</if>>
                                                                <thead>
                                                                <tr>
                                                                    <th style='width:50px;'></th>
                                                                    <th style="text-align: center">属性名称</th>
                                                                    <th style="text-align: center">属性值</th>
                                                                </tr>
                                                                </thead>
                                                                <tbody id="attr-items{$k+1}">
                                                                <volist name="item.attribute" id="attribute">
                                                                    <tr>
                                                                        <td>
                                                                            <a href="javascript:;" onclick="deleteAttr(this)" title="删除"><i class='fa fa-remove'></i></a>
                                                                        </td>
                                                                        <td>
                                                                            <input class="form-control" name="attribute_title{$k+1}[]" value="{$key}">
                                                                        </td>
                                                                        <td>
                                                                            <input class="form-control" name="attribute_value{$k+1}[]" value="{$attribute}">
                                                                        </td>
                                                                    </tr>
                                                                </volist>
                                                                </tbody>
                                                            </table>
                                                            <a href="javascript:;" onclick="addAttrs()" class="btn btn-default"  title="添加属性"><i class='fa fa-plus'></i> 添加属性</a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </volist>
                                        </div>
                                    </div>
                                </section>
                            </div>

                            <div class="tab-pane" id="more">
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 关键字</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.keyword">
                                            <input class="form-control" name="keyword" value="{$red_packet['keyword']}">
                                        <else />
                                            <input class="form-control" name="keyword">
                                        </present>
                                        <p class="help-block">多个关键字请用英文逗号 “,” 号隔开</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 推送描述</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.desc">
                                            <textarea class="form-control" rows="5" name="desc" title="请输入推送描述">{$red_packet['desc']}</textarea>
                                        <else />
                                            <textarea class="form-control" rows="5" name="desc" title="请输入推送描述"></textarea>
                                        </present>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 推送封面</label>
                                    <div class="col-lg-6">
                                        <empty name="red_packet.picurl">
                                            <img src="" class="thumbnail preview" width="100px" height="100px" data-preview="uploadFile">
                                            <input name="picurl" type="file" data-action="uploadFile">
                                        <else />
                                            <img src="/{$red_packet['picurl']}" class="thumbnail" width="100px" height="100px" data-preview="uploadFile">
                                            <input type="hidden" name="picurl" value="{$red_packet['picurl']}" data-set="uploadFile">
                                            <input type="file" class="changePic" data-action="uploadFile">
                                        </empty>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="share">
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 分享标题</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.share_title">
                                            <input class="form-control" name="share_title" value="{$red_packet['share_title']}">
                                        <else />
                                            <input class="form-control" name="share_title">
                                        </present>
                                        <p class="help-block">最多16个汉字（如不填写，默认是一起来抢红包雨）</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 分享描述</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.desc">
                                            <textarea class="form-control" rows="5" name="share_desc" title="请输入分享描述">{$red_packet['share_desc']}</textarea>
                                        <else />
                                            <textarea class="form-control" rows="5" name="share_desc" title="请输入分享描述"></textarea>
                                        </present>
                                        <p class="help-block">（如不填写，默认是好多惊喜大奖正在来袭！）</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 分享链接</label>
                                    <div class="col-lg-6">
                                        <present name="red_packet.share_link">
                                            <input class="form-control" name="share_link" value="{$red_packet['share_link']}">
                                        <else />
                                            <input class="form-control" name="share_link">
                                        </present>
                                        <p class="help-block">（如不填写，默认是游戏首页）</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 分享图标</label>
                                    <div class="col-lg-6">
                                        <empty name="red_packet.share_img">
                                            <img src="" class="thumbnail preview" width="100px" height="100px" data-preview="uploadFile11">
                                            <input name="picurl11" type="file" data-action="uploadFile11">
                                        <else />
                                            <img src="/{$red_packet['share_img']}" class="thumbnail" width="100px" height="100px" data-preview="uploadFile11">
                                            <input type="hidden" name="picurl11" value="{$red_packet['share_img']}" data-set="uploadFile11">
                                            <input type="file" class="changePic" data-action="uploadFile11">
                                        </empty>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="audio">
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"> 游戏背景音乐</label>
                                    <div class="col-lg-6">
                                        <input type="hidden" name="background_music" value="{$red_packet_upload['bgm']}">
                                        <input class="" name="bgm" type="file" accept="audio/mpeg" value="{$red_packet_upload['bgm']}">
                                        <p class="help-block">若不上传，则使用默认背景音乐。支持上传mp3格式的音频文件，文件小于500k。</p>
                                        <a href="javascript:;" onclick="showAudio();" class="btn btn-default" title="播放"><i class='fa fa-play'></i> 播放</a>
                                    </div>
                                </div>

                            </div>
                            <button type="submit" class="btn btn-primary">提交</button>
                            <button type="button" class="btn btn-default" onclick="history.go(-1)">返回列表</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="music_player" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <audio id="audio_player" src="/{$red_packet_upload['bgm']}" controls="controls" style="width:100%"></audio>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="/Public/js/common/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/Public/js/common/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/Public/js/common/lang/zh-cn/zh-cn.js"></script>
<script>
    var editor = UE.getEditor('editor-container');
    var content = '<?php if(empty($red_packet["info"])){echo $default_container;}else{ echo $red_packet["info"]; }?>';
    editor.addListener("ready", function () {
        editor.setContent(content);
    });
</script>

<script type="text/javascript" src="/Public/js/common.upload.js"></script>
<script type="text/javascript">
    common.upload.img.init();
</script>
<script type="text/javascript" src="/Public/js/laydate/laydate.js"></script>
<script type="text/javascript">
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    laydate.skin( "molv" );

    $(function () {
        $('#myTab a:first').tab('show');//初始化显示哪个tab

        $('#myTab a').click(function (e) {
            e.preventDefault();//阻止a链接的跳转行为
            $(this).tab('show');//显示当前选中的链接及关联的content
        })

        var audio = $("#audio_player")[0];
        $('#music_player').on('show.bs.modal', function () {
            audio.play();
        })

        $('#music_player').on('hide.bs.modal', function () {
            audio.pause();
        })
    })

    function showAudio(){
        var background_music = $("input[name=background_music]").val();
        if(background_music){
            $("#audio_player").attr("src", background_music);
            $('#music_player').modal('show');
        }else{
            alert("暂无音频文件播放");
        }
    }

    //增加奖项
    function addaward(){
        var award_num = parseInt($("#award_tab li").length) + 1;
        var red_packet_id = $('input[name=id]').val();
        var data = <?php echo json_encode($levels);?>;
        var level_html = '';
        if(award_num <= 10){
            $("input[name=award_num]").val(award_num);
            $("#award_tab li").removeClass('active');
            $("#award_tab").append('<li class="active"><a href="#award'+award_num+'" data-item="" data-toggle="tab">奖项'+award_num+'</a></li>');
            $("#award_content .tab-pane").removeClass('active');
            for(var i in data){
                var d = data[i];
                level_html += "<option value='"+i+"'>"+d+"</option>";
            }
            $("#award_content").append('<div class="tab-pane active" id="award'+award_num+'">'+
                '<input type="hidden" name="item_id'+award_num+'" value="">'+
                '<div class="form-group">'+
                    '<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span> 奖项等级</label>'+
                    '<div class="col-sm-6 col-xs-12">'+
                        '<div class="form-control-static">'+
                            '<select name="level'+award_num+'" class="form-control">'+level_html+''+

                            '</select>'+
                        '</div>'+
                    '</div>'+
                '</div>'+
                '<div class="form-group">'+
                    '<label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项名称</label>'+
                    '<div class="col-lg-6">'+
                        '<input class="form-control valid" title="请输入奖项名称" name="name'+award_num+'">'+
                    '</div>'+
                '</div>'+
                '<div class="form-group">'+
                    '<label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 奖项数量</label>'+
                    '<div class="col-lg-6">'+
                        '<input class="form-control valid" title="请输入奖项数量" name="number'+award_num+'">'+
                    '</div>'+
                '</div>'+
                '<div class="form-group">'+
                    '<label class="col-lg-2 col-sm-2 control-label"><span style="color:red">*</span> 中奖概率(0.00001-100.00000)</label>'+
                    '<div class="col-lg-6">'+
                        '<input class="form-control valid" placeho="请输入中奖概率" name="reserve'+award_num+'">'+
                    '</div>'+
                '</div>'+
                '<div class="form-group">'+
                    '<label class="col-lg-2 col-sm-2 control-label"> 奖项图片</label>'+
                    '<div class="col-lg-6">'+
                        '<img src="" class="thumbnail preview" width="100px" height="100px" data-preview="uploadFile'+award_num+'">'+
                        '<input name="pic'+award_num+'" type="file" data-action="uploadFile'+award_num+'">'+
                        '<p class="help-block">建议上传图片尺寸：80*60</p>'+
                    '</div>'+
                '</div>'+
                '<div class="form-group">'+
                    '<label class="col-lg-2 col-sm-2 control-label">自定义属性</label>'+
                    '<div class="col-lg-6">'+
                        '<table class="table" id="attr-table'+award_num+'" style="display:none">'+
                            '<thead>'+
                                '<tr>'+
                                    '<th style="width:50px;"></th>'+
                                    '<th style="text-align: center">属性名称</th>'+
                                    '<th style="text-align: center">属性值</th>'+
                                '</tr>'+
                            '</thead>'+
                            '<tbody id="attr-items'+award_num+'">'+
                            '<volist name="attributes" id="attribute">'+
                                '<tr>'+
                                    '<td>'+
                                        '<a href="javascript:;" onclick="deleteAttr(this)" title="删除"><i class="fa fa-remove"></i></a>'+
                                    '</td>'+
                                    '<td>'+
                                        '<input class="form-control" name="attribute_title'+award_num+'[]" value="">'+
                                    '</td>'+
                                    '<td>'+
                                        '<input class="form-control" name="attribute_value'+award_num+'[]" value="">'+
                                    '</td>'+
                                '</tr>'+
                            '</volist>'+
                            '</tbody>'+
                        '</table>'+
                        '<a href="javascript:;" onclick="addAttrs()" class="btn btn-default"  title="添加属性"><i class="fa fa-plus"></i> 添加属性</a>'+
                    '</div>'+
                '</div>'+
            '</div>');
            //上传图片
            common.upload.img.init();
        }else{
            alert('最多添加10个奖项！');
        }
    }

    //减少奖项
    function deleteaward(){
        if(!confirm('确认删除该奖项吗？')) return false;
        var award_num = parseInt($("#award_tab li").length);
        var red_packet_id = $('input[name=id]').val();
        if(award_num>1){
            //编辑时ajax删除奖项表一条记录，新增时不用
            if(red_packet_id != -1){        //编辑红包雨
                var item_id = $('#award_tab .active a').attr('data-item');
                if(item_id){
                    $.ajax({
                        data: {id: item_id},
                        dataType: 'json',
                        url: '/User/RedPacket/deleteItem',
                        type: 'get',
                        success: function (res) {}
                    });
                }
                $("input[name=award_num]").val(award_num-1);
                $("#award_tab .active").remove();
                $("#award_tab li:last").addClass('active');
                $("#award_content .tab-pane.active").remove();
                $("#award_content .tab-pane:last").addClass('active');
            }else{      //新增红包雨
                $("input[name=award_num]").val(award_num-1);
                $("#award_tab .active").remove();
                $("#award_tab li:last").addClass('active');
                $("#award_content .tab-pane.active").remove();
                $("#award_content .tab-pane:last").addClass('active');
            }
        }else{
            alert('抱歉无法删除，奖项至少保留一个');
        }
    }

    function addAttr1(){
        $("#attr-table1").show();
        $("#attr-items1").append('<tr>'+
            '<td>'+
                '<a href="javascript:;" onclick="deleteAttr(this)" title="删除"><i class="fa fa-remove"></i></a>'+
            '</td>'+
            '<td>'+
                '<input class="form-control" name="attribute_title1[]" value="">'+
            '</td>'+
            '<td>'+
                '<input class="form-control" name="attribute_value1[]" value="">'+
            '</td>'+
        '</tr>');
    }

    function addAttrs(){
        var n = $("#award_tab").find(".active").index() + 1;
        $("#attr-table"+n).show();
        $("#attr-items"+n).append('<tr>'+
            '<td>'+
                '<a href="javascript:;" onclick="deleteAttr(this)" title="删除"><i class="fa fa-remove"></i></a>'+
            '</td>'+
            '<td>'+
                '<input class="form-control" name="attribute_title'+n+'[]" value="">'+
            '</td>'+
            '<td>'+
                '<input class="form-control" name="attribute_value'+n+'[]" value="">'+
            '</td>'+
        '</tr>');
    }

    function deleteAttr(o){
        $(o).parent().parent().remove();
    }

    function formcheck() {
        var ret = true;
        //奖项设置检查
        var award_num = parseInt($("#award_tab li").length);
        $('#award').find('.valid').each(function(){
            if($(this).val() == ''){
                $('#myTab a:eq(1)').tab('show');
                var tab = $(this).closest('.tab-pane').attr('id');
                tab = tab.replace('award','');
                tab = parseInt(tab) - 1;
                $('#award_tab li:eq('+tab+')').find('a').tab('show');
                //$(this).tooltip('show');
                //$(this).on('click', function(){$(this).tooltip('destroy');});
                alert($(this).attr('title'));
                ret = false;
                return ret;
            }
        })

        if(ret == true){
            //基础设置检查
            $('#basic').find('.valid').each(function(){
                if($(this).val() == ''){
                    $('#myTab a:eq(0)').tab('show');
                    //$(this).tooltip('show');
                    //$(this).on('click', function(){$(this).tooltip('destroy');});
                    alert($(this).attr('title'));
                    ret = false;
                    return ret;
                }
            })
        }
        return ret;
    }
</script>
